{include file='common/_meta' /}
<style>
.layui-input-block .layui-form-select .layui-anim-upbit dd
{
    white-space: nowrap;
    max-height: 100%
}
.layui-form-select dl dd, .layui-form-select dl dt {
    white-space: nowrap;
}
blockquote h1,blockquote h2,blockquote h3{
    display: inline-block;
}
.layui-elem-quote ul li img{max-width: 100%}
</style>
<body>
<div class="container">

    <div class="layui-row">
        <div class="layui-col-md12 breadcrumb">
            <span class="layui-breadcrumb">
                <a><cite>发送短信</cite></a>
                <a><cite>个性短信</cite></a>
            </span>
        </div>
    </div>

    <div class="layui-fluid" style="background-color: #fff;overflow-x: hidden;min-height: 90vh">

        <div class="layui-col-xs12 layui-col-md6">
        <div class="layui-row" style="padding-top: 10px;">
            <blockquote class="layui-elem-quote">
                <ul style="font-size:22px;line-height:30px">
                    {volist name="send_attentiontxt" id="st"  }
                    <li>{$st|raw}</li>
                    {/volist}
                    <li style="color:red;font-size:28px;line-height:30px">特别注意:</li>
                    <li style="color:red;font-size:28px;line-height:30px">表格的手机号码列单元格式必须选择常规</li>
                    <li><img style="border:3px solid red" src="/static/img/154254124.png" alt=""></li>
                    <!-- <li>注意事项：</li>
                    <li>* 目标号码手动输入格式：手机号+英文逗号+手机号+...；例子：18813266666,18813266666；</li>
                    <li>* 目标号码文件导入格式：每一行一个号码，文件格式为 txt ；</li>
                    <li>* 短信内容变量用符号：{0}或{1}或... 代替，例：验证码：{0} ，地址：{1} ；</li>
                    <li>* 短信内容变量必须从{0}开始 ，依次递增；</li>
                    <li>* 填写的变量个数必须与模板变量的个数相同 ；</li>
                    <li>* 目标号码最多20000个 ；</li> -->
                    {if condition="session('user_type') == 'admin' "}
                    <li><a href="javascript:;" style="color:#2B22F9" onclick="openedit()">编辑</a></li>
                    {/if}
                    <li>普通短信-个性发送模板文件.xlsx <a style="color:#2B22F9" href="/uploads/abc.xlsx" download="普通短信发送模板文件.xlsx">点击下载</a></li>
                    <li>视频短信-个性发送模板文件.xlsx <a style="color:#2B22F9" href="/uploads/abc2.xlsx" download="视频短信发送模板文件.xlsx">点击下载</a></li>
                </ul>
            </blockquote>
        </div>
        <div class="layui-row">
            <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">

                <div class="layui-tab-content">
                    <div class="layui-tab-item layui-show">
                        <form class="layui-form" action="" lay-filter="form1" id="form-article1" enctype="multipart/form-data">

                            {if condition="session('user_type') == 'admin' "}

                            <div class="layui-row">
                                <div class="layui-form-item">
                                    <label class="layui-form-label"><span class="custom-color-red">*</span>选择渠道：</label>
                                    <div class="layui-input-block">
                                        <select name="cha" id="cha" lay-filter="cha" lay-search lay-verify="required">
                                            <option value=""></option>
                                            {volist name='cha' id='c'}
                                            <option value="{$c.channel_id}"> {$c.company_name} ({$c.channel_id})</option>
                                            {/volist}
                                        </select>
                                    </div>
                                </div>
                            </div>

                            <div class="layui-row">
                                <div class="layui-form-item">
                                    <label class="layui-form-label"><span class="custom-color-red">*</span>短信类型：</label>
                                    <div class="layui-input-block">
                                        <select name="sms_y" lay-search lay-verify="required">
                                            <option value="1">普通短信</option>
                                            <option value="2">视频短信</option>
                                        </select>
                                    </div>
                                </div>
                            </div>
                            {/if}

                            <div class="layui-row is-files">
                                <div class="layui-form-item layui-col-sm12">
                                    <label class="layui-form-label"><span class="custom-color-red">*</span>目标文件：</label>
                                    <div class="layui-input-inline">
                                        <input type="text" class="layui-input uploadfile-name" disabled>
                                    </div>
                                    <div class="layui-input-inline">
                                        <button type="button" class="layui-btn custom-sm-fluid"><i class="layui-icon layui-icon-upload"></i>浏览文件</button>
                                        <input type="file" multiple name="phonesfile" style="position: absolute;top: 0px;left: 0px;bottom: 0px;right: 0px;opacity: 0;filter:alpha(opacity=0);" accept=".xlsx" class="change-update" lay-verify="required">
                                    </div>
                                </div>
                            </div>

                            <div class="layui-row is-no-files">
                                <div class="layui-form-item layui-form-text">
                                    <label class="layui-form-label"><span class="custom-color-red">*</span>备注：</label>
                                    <div class="layui-input-block">
                                        <textarea name="message" class="layui-textarea" lay-verify="required"></textarea>
                                    </div>
                                 </div>
                            </div>

                            <div class="layui-row">
                                <div class="layui-form-item">
                                    <label class="layui-form-label">定时发送：</label>
                                    <div class="layui-input-block">
                                        <input type="checkbox" name="is_dingshi" value="1" title="" lay-skin="primary" lay-filter="is_dingshi">
                                    </div>
                                </div>
                            </div>

                            <div class="layui-row layui-hide is-dingshitime">
                                <div class="layui-form-item">
                                    <label class="layui-form-label"><span class="custom-color-red">*</span>定时时间：</label>
                                    <div class="layui-input-block">
                                        <input type="text" class="layui-input" name="dingshitime" id="dingshitime1">
                                    </div>
                                </div>
                            </div>

                            <div class="layui-row">
                                <div class="layui-form-item">
                                    <div class="layui-input-block">
                                        <button class="layui-btn custom-sm-fluid" lay-submit lay-filter="formDemo1">发送</button>
                                    </div>
                                </div>
                            </div>

                        </form>
                    </div>
                </div>
            </div>
        </div>
        </div>
        <div class="layui-col-xs12 layui-col-md6">
        <div class="layui-hide" id="result-msg">
            <div class="layui-fluid" style="padding-top: 30px;">
                <fieldset class="layui-elem-field layui-field-title">
                    <legend>反馈信息</legend>
                    <div class="layui-field-box result-msg" style="padding-left: 20px;padding-right: 20px;color: #333;font-size: 14px;">
                        ...
                    </div>
                </fieldset>
            </div>
        </div>
        </div>
    </div>
</div>
<div hidden>
<textarea id="openedit">{$send_attentiontxt_e}</textarea>
</div>
{include file="common/_footer"}

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript">
//保存的短信
layui.use(['layer', 'form', 'jquery', 'element', 'laydate'], function() {

    var layer   = layui.layer;
    var form    = layui.form;
    var $       = layui.jquery;
    var element = layui.element;
    var laydate = layui.laydate;

    //定时
    laydate.render({
        elem: '#dingshitime1'
        ,type: 'datetime'
        ,value: '{$thistime}'
    });

    //是否定时发送
    form.on('checkbox(is_dingshi)', function(data) {

        var parent = $(data.elem).parents('form');

        if (data.elem.checked) {

            parent.find('.is-dingshitime').removeClass('layui-hide');
        } else {

            parent.find('.is-dingshitime').addClass('layui-hide');
        }
    });

    //选择文件，显示文件名及路径
    $('form').on('change', '.change-update', function(event) {

        $(this).parents('.layui-form-item').find('.uploadfile-name').val(this.value);
    });


    form.on('submit(formDemo1)', function(data) {

        article_submit();
        return false;
    });

    function article_submit() {
        layer.confirm("提交前请确认文件格式无误",{title:"温馨提示",btn: ['可以提交', '我再看看']},function(index){   
            layer.close(index);
            var indexload = layer.load(0);
            var formData = new FormData($('#form-article1')[0]);
            var dingshitime = 0;

            if (formData.get('is_dingshi') == 1) {

                dingshitime = 1;
            }

            $.ajax({
                type : "POST",
                url  : "{:url('SendSelfdom/upflie')}",
                cache: false,
                data: formData,
                processData: false,
                contentType: false,
                success : function(e) {
                    $('#result-msg').removeClass('layui-hide');
                    layer.close(indexload);
                    if(e.code == 200)
                    {
                        layer.alert(e.msg, {icon: 1},function(index){
                            layer.close(index);
                        })
                        // layer.msg('发送成功', {icon: 6, time:1500});
                        $('.result-msg').css("color","green");
                        $('#form-article1')[0].reset();
                        dingshitime = 0;
                    }else{
                        layer.alert(e.msg, {icon: 2},function(index){
                            layer.close(index);
                        })
                        // layer.msg('发送失败', {icon: 5, time:1500});
                        $('.result-msg').css("color","red");
                    }
                    $('.result-msg').html(e.msg);

                    parent.getapplycount_fun();//刷新余额

                },error:function() {

                    layer.close(indexload);
                    layer.msg('提交失败，请检查网络',{icon: 5,time:1500});
                    $dingshitime = 0;
                }
            });
        });

    }
});
{if condition="session('user_type') == 'admin' "}
//设置注意事项
function openedit()
{
    layer.prompt(
        {
            title: "设置注意事项",
            formType: 2, //输入框类型，支持0（文本）默认1（密码）2（多行文本）
            value: $("#openedit").val(), //初始时的值，默认空字符
            maxlength: 1000, //可输入文本的最大长度，默认500
            area: ['500px', '350px'] //自定义文本域宽高
        },
        function(value, index, elem){
            layer.close(index);

            var indexload = layer.load(0);

            $.ajax({
                type : "POST",
                url  : "{:url('SendNote/attentiontxt')}",
                data : {"atxt":value,"type":3},
                success : function(e) {

                    location.reload();

                    layer.msg(e, {icon: 6, time:1000});

                    layer.close(indexload);

                }, error:function() {
                    layer.close(indexload);
                }
            });
        }
    )
}
{/if}


</script>
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>